<script setup lang="ts">
import {
  Bell,
  Document,
  HomeFilled,
  Menu as IconMenu,
  InfoFilled,
  Search
} from '@element-plus/icons-vue'
import { useRouter, useRoute } from 'vue-router';
import useDetailStore from '@/store/modules/hospitalDetail';
import { onMounted } from 'vue';

onMounted(() => {
  detailStore.getHospital($route.query.hoscode as string)
  detailStore.getDepartment($route.query.hoscode as string)
})

const detailStore = useDetailStore()
const $router = useRouter()
const $route = useRoute()
const changeActive = (path: string) => {
  $router.push({ path, query: { hoscode: $route.query.hoscode } })
}
</script>



<template>
  <div class="hospital">
    <!-- 左侧菜单 -->
    <div class="menu">
      <div class="top">
        <el-icon>
          <HomeFilled />
        </el-icon>
        <span>/ 医院详情信息</span>
      </div>
      <el-menu :default-active="$route.path" class="el-menu-vertical-demo">
        <el-menu-item index="/hospital/register" @click="changeActive('/hospital/register')">
          <el-icon><icon-menu /></el-icon>
          <span>预约挂号</span>
        </el-menu-item>
        <el-menu-item index="/hospital/detail" @click="changeActive('/hospital/detail')">
          <el-icon>
            <document />
          </el-icon>
          <span>医院详情</span>
        </el-menu-item>
        <el-menu-item index="/hospital/notice" @click="changeActive('/hospital/notice')">
          <el-icon>
            <Bell />
          </el-icon>
          <span>预约须知</span>
        </el-menu-item>
        <el-menu-item index="/hospital/close" @click="changeActive('/hospital/close')">
          <el-icon>
            <InfoFilled />
          </el-icon>
          <span>停诊信息</span>
        </el-menu-item>
        <el-menu-item index="/hospital/search" @click="changeActive('/hospital/search')">
          <el-icon>
            <Search />
          </el-icon>
          <span>查询/取消</span>
        </el-menu-item>
      </el-menu>
    </div>
    <!-- 右侧展示路由组件 -->
    <div class="content">
      <router-view></router-view>
    </div>
  </div>
</template>



<style scoped lang="scss">
.hospital {
  display: flex;
  margin: 10px 0;

  .menu {
    flex: 2;
    display: flex;
    flex-direction: column;
    align-items: center;

    .top {
      color: #7f7f7f;
      margin-bottom: 10px;
    }
  }

  .content {
    flex: 8;
  }
}
</style>